import QtQuick 2.12
import QtQuick.Controls 2.5
import QtLocation 5.6
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
import QtQuick.Dialogs 1.2

ApplicationWindow {
    id: window
    width: 640
    height: 480
    visible: true
    title: qsTr("Menu Demo")

    minimumWidth: 100
    minimumHeight: 50
    property int butm_anim: 0

    MainMenuBar{ id:mainMenu }
    MouseRightButtonMenu { id:rightButtonMenu }

    Loader {
        id:loaderSubWindow
    }

    menuBar: mainMenu

    MouseArea {
        anchors.fill:parent
        acceptedButtons: Qt.LeftButton | Qt.RightButton
        onClicked: {
            if(mouse.button == Qt.RightButton) {
                rightButtonMenu.popup()
            }
        }
    }

    Timer{
        id: progressTestTimer
        running: false
        repeat: true
        interval: 5
        onTriggered:{
            progress.progress ++
            if(progress.progress >= 100) {
                stop();
                running = false;
            }
        }
    }

//    CustomWindow_Message {
//        id: messageBox
//    }
    CustomMessage_Popup {
        id:messageBox
        onSClosed: {
            console.log("popup closed!")
        }
    }

    Column {
        spacing: 10
        anchors.fill: parent

        CustomEdit_ScrollBar {
            id:editText
            width: parent.width
            height: 100
        }

        CustomButton_Progress {
            id:progress
            width: 100
            height: 60
            onSClicked: {
                progress.progress = 0 ;
                progressTestTimer.running = true
                console.log("prog click")
            }
        }

        Button {
            text: qsTr("Popup Test")
            onClicked: {
                messageBox.popupMessage("这是一个消息弹出窗口。这是一个消息弹出窗口。这是一个消息弹出窗口。这是一个消息弹出窗口。这是一个消息弹出窗口。这是一个消息弹出窗口。")
            }
        }

        CustomButton_Switch {
            id:switchButton
            width: 50
            height: 35
            //checked: true//在宽度与组件默认大小不一至的情况下，这里立即改变属性,动画会不对
            onSSwitchChanged: {
                console.log("status:",checked)
            }
            Component.onCompleted: {//等待加载完成后，再改变属性
                switchButton.checked = true
            }
        }
    }
}
